﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace Esign.Net.Output
{
    [Serializable]
    public class DocTemplates
    {
        [Serializable]
        public class TemplateOutput
        {
            /// <summary>
            /// 控件列表（控件ID和 控件Key 二选一传值）
            /// </summary>
            [JsonProperty("components")]
            public IList<Component> Components { get; set; }

            [JsonProperty("createTime")]
            public long CreateTime { get; set; }

            [JsonProperty("docTemplateId")]
            public string DocTemplateId { get; set; }

            [JsonProperty("docTemplateName")]
            public string DocTemplateName { get; set; }

            [JsonProperty("fileDownloadUrl")]
            public string FileDownloadUrl { get; set; }

            [JsonProperty("updateTime")]
            public long UpdateTime { get; set; }
        }

        public class ComponentPosition
        {

            [JsonProperty("componentPageNum")]
            public int ComponentPageNum { get; set; }

            [JsonProperty("componentPositionX")]
            public double ComponentPositionX { get; set; }

            [JsonProperty("componentPositionY")]
            public double ComponentPositionY { get; set; }
        }

        public class Option
        {
            [JsonProperty("optionContent")]
            public string OptionContent { get; set; }

            [JsonProperty("optionOrder")]
            public int OptionOrder { get; set; }

            [JsonProperty("selected")]
            public bool Selected { get; set; }
        }

        public class ComponentSpecialAttribute
        {

            [JsonProperty("dateFormat")]
            public string DateFormat { get; set; }

            [JsonProperty("imageType")]
            public object ImageType { get; set; }

            [JsonProperty("options")]
            public IList<Option> Options { get; set; }
        }

        public class ComponentSize
        {

            [JsonProperty("componentHeight")]
            public int ComponentHeight { get; set; }

            [JsonProperty("componentWidth")]
            public int ComponentWidth { get; set; }
        }

        public class NormalSignField
        {

            [JsonProperty("dateFormat")]
            public object DateFormat { get; set; }

            [JsonProperty("showSignDate")]
            public int ShowSignDate { get; set; }

            [JsonProperty("signFieldStyle")]
            public int SignFieldStyle { get; set; }
        }

        /// <summary>
        /// 模板中的控件列表信息
        /// </summary>
        [Serializable]
        public class Component
        {
            /// <summary>
            /// 控件ID（设置合同模板时由e签宝系统自动生成）
            /// </summary>
            [JsonProperty("componentId")]
            public string ComponentId { get; set; }

            /// <summary>
            /// 控件Key（设置合同模板时由用户自定义）
            /// </summary>
            [JsonProperty("componentKey")]
            public string ComponentKey { get; set; }

            /// <summary>
            /// 控件名称
            /// </summary>
            [JsonProperty("componentName")]
            public string ComponentName { get; set; }

            [JsonProperty("componentPosition")]
            public DocTemplates.ComponentPosition ComponentPosition { get; set; }

            [JsonProperty("componentSize")]
            public DocTemplates.ComponentSize ComponentSize { get; set; }

            [JsonProperty("componentSpecialAttribute")]
            public DocTemplates.ComponentSpecialAttribute ComponentSpecialAttribute { get; set; }

            [JsonProperty("componentType")]
            public int ComponentType { get; set; }

            [JsonProperty("normalSignField")]
            public DocTemplates.NormalSignField NormalSignField { get; set; }

            [JsonProperty("originCustomComponentId")]
            public string OriginCustomComponentId { get; set; }

            [JsonProperty("remarkSignField")]
            public object RemarkSignField { get; set; }
        }
    }
}
